import Vue from 'vue'
import Vuex from 'vuex'

import mutations from './mutations'
import actions from './actions'
import getters from './getters'
import moduleA from './modules/moduleA'

// 1.安装插件
Vue.use(Vuex)

// 2.创建对象

// 一定要放在引用的前面不然会报错,找不到
const state = {
    counter : 0,
    students: [
        {id:110,name:'why',age:18},
        {id:111,name:'lion',age:21},
        {id:112,name:'lee',age:29},
    ],
    info:{
        name:'lion',
        age:18,
        height:180
    }
}

const store = new Vuex.Store({
    // 数据
    state,
    // 同步操作
    mutations,
    //异步操作,用来接收api
    actions,
    //相当于计算属性
    getters,
    // 模块
    modules:{
        a : moduleA
    }
})


// 3.导出store对象
export default store;